<%@ page import="com.java2007.hotel.pojo.DetailOrder" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/1/26
  Time: 15:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/front/detail/style/css/index.css" />
    <script type="text/javascript">
        // 通知服务员结账
        function callPay(node) {
            var orderId = node.lang;
            window.location.href = "jiezhang.html";
        }
    </script>
</head>

<body style="text-align: center">
<div id="all">
    <div id="menu">
        <!-- 餐车div -->
        <div id="count">
            <table align="center" width="100%">
                <tr height="40">
                    <td align="center" width="20%">菜名</td>
                    <td align="center" width="20%">单价</td>
                    <td align="center" width="20%">数量</td>
                    <td align="center" width="20%">小计</td>
                </tr>


                <%
                    List<DetailOrder>detailOrdersByUserIdAndUnOrders = (List<DetailOrder>) request.getAttribute("detailOrdersByUserIdAndUnOrders");
                    Long totalAllPrice= 0L;
                    for (DetailOrder detailOrdersByUserIdAndUnOrder : detailOrdersByUserIdAndUnOrders) {
                        totalAllPrice += detailOrdersByUserIdAndUnOrder.getFoodTotalPrice();
                    }
                    pageContext.setAttribute("totalAllPrice",totalAllPrice);
                %>

                <c:forEach items="${detailOrdersByUserIdAndUnOrders}" var="detailOrdersByUserIdAndUnOrder" varStatus="status">

                    <tr height="60">
                        <td align="center" width="20%">${detailOrdersByUserIdAndUnOrder.foodName}</td>
                        <td align="center" width="20%">￥${detailOrdersByUserIdAndUnOrder.foodPrice/100.0}</td>
                        <td align="center" width="20%">${detailOrdersByUserIdAndUnOrder.foodCount}</td>
                        <td align="center" width="20%">${detailOrdersByUserIdAndUnOrder.foodTotalPrice/100.0}</td>
                    </tr>

                </c:forEach>



                <tr>
                    <td colspan="6" align="right">总计:
                        <span style="font-size:36px;">&yen;</span>
                        <label
                                id="counter" style="font-size:36px">${totalAllPrice/100.0}</label>
                    </td>
                </tr>
                <tr>
                    <td colspan="6" style="margin-left: 100px; text-align: center;"align="right">
                        <input type="hidden" name="bId" value="">
                        <input type="button" value="结账" class="btn_next" lang="" onclick="callPay()" />
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <!-- 右边菜系列表，菜品搜索框  -->
    <div id="dish_class">
        <div id="dish_top">
            <ul>
                <li class="dish_num"></li>
                <li>
                    <a href="${pageContext.request.contextPath}/front/detailServlet?method=selectAll">
                        <img src="${pageContext.request.contextPath}/front/detail/style/images/call2.gif" />
                    </a>
                </li>
            </ul>
        </div>

        <div id="dish_2">
            <ul>
                <c:forEach items="${foodTypes}" var="foodType" varStatus="status">
                    <li>
                        <a href="${pageContext.request.contextPath}/front/foodServlet?method=selectByFoodType&currentPageNo=1&foodTypeId=${foodType.id}">${foodType.name}</a>
                    </li>

                </c:forEach>
            </ul>
        </div>
        <div id="dish_3">
            <!-- 搜索菜品表单  -->
            <form action="${pageContext.request.contextPath}/front/foodServlet" method="post">
                <table width="166px">
                    <tr>
                        <td>
                            <input type="text" id="dish_name" name="foodName" class="select_value" />
                            <input type="hidden" value="selectFood" name="method">
                            <input type="hidden" value="1" name="currentPageNo">
                        </td>
                    </tr>
                    <tr>
                        <td><input type="submit" id="sub" value="" /></td>
                    </tr>
                    <tr>
                        <td>
                            <a href="${pageContext.request.contextPath}/front/foodServlet?method=selectAll&currentPageNo=1">
                                <img src="${pageContext.request.contextPath}/front/detail/style/images/look.gif" />
                            </a>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

</div>
</body>
<script>
    function callPay() {
        location.href = "${pageContext.request.contextPath}/front/orderServlet?method=updateStatus&orderNumber=${orderNumber}&totalAllPrice=${totalAllPrice}";
    }
</script>
</html>

